package cn.nuc.controller.warning;

import cn.nuc.controller.login.LoginController;
import cn.nuc.pojo.sensorfire.Sensor;
import cn.nuc.service.sensorfire.ISensorService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;


@Service
public class WaringController {
    @Autowired
    private ISensorService sensorService;
    @RabbitListener(queues = {"zhongbei.nuc" , "wentaosi.nuc"})
    public void receive(String  id){
        List<Sensor> sensorList = sensorService.list(new QueryWrapper<Sensor>().eq("id", id));
        if(sensorList.size() != 0){
          Sensor  sensor = sensorList.get(0);
          LoginController.session.setAttribute("sensor" , sensor.getLocation());
        }
    }
}
